<div class="row" style="border-bottom: 10px solid #EFEFEF;padding:10px;">
	<div class="col-lg-8">
		<div class="ukefu-measure">
			<div class="ukefu-bt"> 
				<div	class="layui-icon ukewo-btn ukefu-content-ind"><img src="/images/weixin.jpg" style="width:60px;height:60px;"></div>
				<div class="ukefu-bt-text">
					<div class="ukefu-bt-text-title"
						style="font-weight:400;font-size:24px;border-bottom:1px solid #dedede;">
							${snsAccount.name!''}
							<span style="font-size:15px;color:#AAAAAA;">公众号创建时间：${snsAccount.createtime!?string("yyyy-MM-dd HH:mm:ss")}</span>
					</div>
					<div class="ukefu-bt-text-content" style="">${snsAccount.name!''}</div>
				</div>
			</div>
		</div>
	</div>
	<div class="col-lg-4">
		<form class="layui-form" action="/admin/weixin/update.html"	method="post">
			<div class="layui-form-item">
				<label class="layui-form-label">
					人工坐席：
				</label>
				<div class="layui-input-block ukefu-agent-switch" style="padding-top:0px;">
					<input type="checkbox" name="switch" <#if snsAccount.agent?? && snsAccount.agent == true>checked</#if> lay-filter="agent" lay-skin="switch" value="1" lay-text="开启|关闭">
				</div>
			</div>
		</form>
	</div>
</div>
<div class="row" style="border-bottom: 10px solid #EFEFEF;padding:10px;">
	<div class="col-lg-12">
		<span style="font-weight:600;">接口地址：</span>${schema!''}://${hostname!''}<#if port?? && port != '80'>:${port?string('###')}</#if>/im/weixin/${snsAccount.snsid!''}
		<span style="font-weight:600;margin-left:50px;">Token：</span>${snsAccount.token!''}
		<span style="font-weight:600;margin-left:50px;">AppID：</span>${snsAccount.appkey!''}	
	</div>
</div>
<div class="ukefu-tab-title" style="margin-left: 0px;">
	<#include "/admin/channel/weixin/include/top.html">
</div>

<div class="row">
	<div class="col-lg-12" style="display: inline-flex;">
		<!--  ， 待扩展功能，支持 多级 关键词指令，  支持 从关键词 到 API访问
		<div class="ukefu-imr-tree">
			<h1 class="site-h1" style="border-top:1px solid #e6e6e6;">
				关键词目录
			</h1>
			<div id="imr" class="ztree">
			</div>
			<SCRIPT type="text/javascript">
					var setting = {
						data: {
							simpleData: {
								enable: true
							}
						}
					};
			
					var zNodes =[
						{ id:"setting", pId:0, name:"应答设置", open:true , iconSkin:'imr'},
						{ id:1, pId:0, name:"系统关键词", open:true , iconSkin:'imr'},
						{ id:11, pId:1, name:"微信事件消息", open:true , iconSkin:'imr'},
						{ id:12, pId:1, name:"微信指令消息", open:true , iconSkin:'imr'},
						{ id:2, pId:0, name:"业务关键词", open:true , iconSkin:'imr'},
						{ id:21, pId:2, name:"保单查询", open:true , iconSkin:'imr'},
						{ id:211, pId:21, name:"财险保单" , iconSkin:'imr'},
						{ id:212, pId:21, name:"寿险保单" , iconSkin:'imr'},
						{ id:213, pId:21, name:"其他保单" , iconSkin:'imr'}
					];
			
					$(document).ready(function(){
						$.fn.zTree.init($("#imr"), setting, zNodes);
						var zTree = $.fn.zTree.getZTreeObj("imr");

						zTree.selectNode(zTree.getNodeByParam("id" , "setting"));
					});
			</SCRIPT>
		</div>
		 -->
		<div class="ukefu-imr-keyword" style="margin-left:0px;">
			<h1 class="site-h1" style="border-top:1px solid #e6e6e6;">
				关键词列表<#if agentServiceList??>（${agentServiceList.totalElements}）</#if>
				<span style="float:right;">
					<button class="layui-btn layui-btn-sm green" href="/admin/weixin/imr/add.html?said=${snsAccount.id!''}" data-toggle="ajax" data-width="950" data-height="600" data-title="创建新关键词">
						创建新关键词
					</button>
				</span>
			</h1>
			<table class="layui-table" lay-skin="line">
				<thead>
					<tr class="design-sortable-tr">
						<th>名称</th>
						<th>请求</th>
						<th>响应</th>
						<th>接待方式</th>
						<th>创建时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<#if instructionList?? && instructionList.content?? && instructionList.content?size gt 0>
					<#list instructionList.content as ins>
					<tr class="tdHasContorllor design-dropable-td">
						<td class=" first_td_head">
							${ins.name!''}
						</td>
						<td>
							<#if ins.matcherule?? && ins.matcherule == 'keyword'>
								关键词：${ins.keyword!''}
							<#elseif ins.matcherule?? && ins.matcherule == 'message'>
								消息类型：
								<#if ins.messagetype?? && ins.messagetype == "text">文本</#if>
								<#if ins.messagetype?? && ins.messagetype == "image">图片</#if>
								<#if ins.messagetype?? && ins.messagetype == "voice">语音</#if>
								<#if ins.messagetype?? && ins.messagetype == "video">视频</#if>
								<#if ins.messagetype?? && ins.messagetype == "location">地理位置</#if>
							<#elseif ins.matcherule?? && ins.matcherule == 'event'>
								事件类型：
								<#if ins.eventype?? && ins.eventype == "subscribe">关注</#if>
								<#if ins.eventype?? && ins.eventype == "click">自定义菜单（${ins.keyword!''}）</#if>
							</#if>
						</td>
						<td>
							<#if ins.adapter?? && ins.adapter == "text">回复文本消息：${ins.memo!''}</#if>
							<#if ins.adapter?? && ins.adapter == "media">回复多媒体消息</#if>
							<#if ins.adapter?? && ins.adapter == "agent">转人工坐席</#if>
							<#if ins.adapter?? && ins.adapter == "inter">访问接口</#if>
							<#if ins.adapter?? && ins.adapter == "xiaoe">智能机器人</#if>
						</td>
						<td>
							<#if !(ins.interfacetype??) || ins.interfacetype == "default">默认</#if>
							<#if ins.interfacetype?? && ins.interfacetype == "skill">技能组</#if>
							<#if ins.interfacetype?? && ins.interfacetype == "agent">坐席</#if>
						</td>
						<td><#if ins.createtime??>${ins.createtime?string('yyyy-MM-dd HH:mm:ss')}</#if></td>
						<td style="white-space:nowrap;width:1%;" nowrap="nowrap">
							<a href="/admin/weixin/imr/edit.html?id=${ins.id!''}&said=${snsAccount.id!''}"	data-toggle="ajax" data-width="950" data-height="600"	data-title="编辑关键词"> 
								<i class="layui-icon">&#xe642;</i> 编辑
							</a> 
							<a href="/admin/weixin/imr/delete.html?id=${ins.id!''}&said=${snsAccount.id!''}" style="margin-left:10px;" data-toggle="tip" data-title="请确认是否删除记录？"> 
								<i class="layui-icon" style="color:red;">&#x1006;</i> 
								删除
							</a>
						</td>
					</tr>
					</#list>
					<#else>
						<tr>
							<td colspan="20" style="height:400px;">
								<div class="ukefu-empty">
									<i class="layui-icon">&#xe63a;</i>
									<div style="">当前没有进行中的对话</div>
								</div>
							</td>
						</tr>
					</#if>
				</tbody>
			</table>
		</div>
	</div>
</div>

<script>
	layui.use('form', function() {
		var form = layui.form;
		form.render(); //更新全部
		form.on("switch(agent)" , function(data){
			if(data.elem.checked){
				loadURL("/admin/weixin/enable.html?id=${snsAccount.id!''}" , null , function(){
					top.layer.alert('启用人工坐席', {icon: 1});
				});
			}else{
				loadURL("/admin/weixin/disable.html?id=${snsAccount.id!''}" , null , function(){
					top.layer.alert('关闭人工坐席', {icon: 1});
				});
			}
		})
	});
	layui.use('element', function(){
		var element = layui.element;
	});
</script>